
#include "rect_f.h"

namespace webrtc {

RectF::RectF() : left(0), top(0), right(0), bottom(0) {}
RectF::RectF(float left, float top, float right, float bottom)
    : left(left), top(top), right(right), bottom(bottom) {}

float RectF::Width() const {
  return right - left;
}
float RectF::Height() const {
  return bottom - top;
}

float RectF::CenterX() const {
  return (left + right) * 0.5f;
}

float RectF::CenterY() const {
  return (top + bottom) * 0.5f;
}

void RectF::Set(float left, float top, float right, float bottom) {
  this->left = left;
  this->top = top;
  this->right = right;
  this->bottom = bottom;
}

bool RectF::IsEmpty() const {
  return left >= right || top >= bottom;
}

}